﻿using System.Linq;
using ISSMoviePlex.DAL.Models;

namespace ISSMoviePlex.DAL.Repositories
{
    public class MemberRepository : BaseRepository<int, Member, MemberRepository>
    {
        public override Member FindById(int id)
        {
            return Context.Members.SingleOrDefault(m => m.MemberId == id);
        }

        public void SetMemberState(int memberId, MemberState memberState)
        {
            FindById(memberId).MemberState = memberState;
            Context.SaveChanges();
        }

        public void Spend(int memberId, float ammount)
        {
            FindById(memberId).Spend(ammount);
            Context.SaveChanges();
        }
    }
}
